//
//  LPSanHuiYiKeTypeDetailListTableViewCell.m
//  GongXinDangJian
//
//  Created by 刘应平 on 2017/11/30.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "LPSanHuiYiKeTypeDetailListTableViewCell.h"

@interface LPSanHuiYiKeTypeDetailListTableViewCell ()
/**  标题  */
@property (strong, nonatomic) UILabel  *headLine;
/**  类型  */
@property (strong, nonatomic) UILabel  *typeLabel;
/**  时间  */
@property (strong, nonatomic) UILabel  *timeLabel;
/**  图片  */
@property (strong, nonatomic) UIImageView  *theImageView;

@end

@implementation LPSanHuiYiKeTypeDetailListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
    }
    return self;
}


#pragma mark - 界面
- (void)layoutUI{
     [self addSubview:self.theImageView];
    [self addSubview:self.headLine];
    [self addSubview:self.typeLabel];
    [self addSubview:self.timeLabel];
    
   self.theImageView.sd_layout
    .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
    .topSpaceToView(self, 15 * [UIScreen zj_screenHScale])
    .heightIs(15 * [UIScreen zj_screenHScale])
    .widthIs(15 * [UIScreen zj_screenHScale]);
    
    self.headLine.sd_layout
    .leftSpaceToView(self, 20 * [UIScreen zj_screenWScale])
    .topSpaceToView(self, 15 * [UIScreen zj_screenHScale])
    .heightIs(15 * [UIScreen zj_screenHScale])
    .rightSpaceToView(self.theImageView, 10 * [UIScreen zj_screenWScale]);
    
    
    CGFloat width = [CalculateLabelHeight CalculateLabelWidthWithString:@"2017.08.12 22:00:00" font:15 * [UIScreen zj_textFontScale] height:15 * [UIScreen zj_screenHScale]].width;
    
    self.typeLabel.sd_layout
    .leftEqualToView(self.headLine)
    .topSpaceToView(self.headLine, 15 * [UIScreen zj_screenHScale])
    .heightIs(15 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 80 * [UIScreen zj_screenWScale] - width);
    
    
    
    self.timeLabel.sd_layout
    .rightSpaceToView(self, 20 * [UIScreen zj_screenWScale])
    .topEqualToView(self.typeLabel)
    .heightIs(15 * [UIScreen zj_screenHScale])
    .widthIs(width + 20 * [UIScreen zj_screenWScale]);
    
    TenGrayShadowView *under = [TenGrayShadowView new];
    under.backgroundColor = [UIColor themeGrayColor];
    [self addSubview:under];
    under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(5 * [UIScreen zj_screenHScale]);
}


- (void)setModel:(LPSanHuiMeetingListModel *)model{
    _model = model;
    self.headLine.sd_layout.heightIs(model.NAMEHEIGHT);
    [self.headLine updateLayout];
    self.headLine.text = model.NAME;
    self.typeLabel.text = model.TYPE_TEXT;
    self.timeLabel.text = model.PUBLISH_DATE;
    if ([model.RES_COUNT integerValue] == 0) {
        self.theImageView.hidden = YES;
    }else{
        self.theImageView.hidden = NO;
    }
}

#pragma mark - getter
- (UILabel *)headLine{
    if (!_headLine) {
        _headLine = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(16.5);
            label;
        });
    }
    return _headLine;
}


- (UILabel *)typeLabel{
    if (!_typeLabel) {
        _typeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(15);
            label;
        });
    }
    return _typeLabel;
}


- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentRight;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(15);
            label;
        });
    }
    return _timeLabel;
}


- (UIImageView *)theImageView{
    if (_theImageView == nil) {
        _theImageView = [UIImageView new];
        _theImageView.contentMode = UIViewContentModeCenter;
        _theImageView.image = [UIImage imageNamed:@"icon_biaoqian"];
    }
    return _theImageView;
}
@end
